package com.example.qxfw.csnl.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.qxfw.common.entity.zy.WaterLoggingPointInfo;
import com.example.qxfw.csnl.mapper.WaterLoggingPointInfoMapper;
import com.example.qxfw.csnl.service.NldglService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NldglServiceImpl implements NldglService {
    @Value("${dmgis.ip}")
    private String dmgisIp;

    @Value("${dmgis.port}")
    private String dmgisPort;
    @Autowired
    private WaterLoggingPointInfoMapper waterLoggingPointInfoMapper;

    @Override
    public WaterLoggingPointInfo insertOneData(WaterLoggingPointInfo waterLoggingPointInfo) {
        int rows = waterLoggingPointInfoMapper.insert(waterLoggingPointInfo);
        if (rows>0){
            return waterLoggingPointInfo;
        } else {
            return null;
        }
    }

    @Override
    public int deleteById(int id) {
        return waterLoggingPointInfoMapper.deleteById(id);
    }

    @Override
    public WaterLoggingPointInfo updateById(WaterLoggingPointInfo waterLoggingPointInfo) {
        int rows = waterLoggingPointInfoMapper.update(waterLoggingPointInfo, new UpdateWrapper<WaterLoggingPointInfo>()
                .eq("id", waterLoggingPointInfo.getId()));
        if (rows>0){
            return waterLoggingPointInfo;
        } else {
            return null;
        }
    }

    @Override
    public List<WaterLoggingPointInfo> selectAllOfWaterLoggingPointInfo() {
        return waterLoggingPointInfoMapper.selectList(null);
    }


}
